<?php
session_start();
//包含头
include '../PHP/head.php';
?>
<?php
//包含bootstrap的顶端按钮
include '../PHP/menu.php';
?>

<br />
<br />
<p class="text-center lead">模块报价项目通知</p>
<?php
if(isset($_GET['project_id'])) {
	//查询编号信息
	require_once ('../FNS/db_fns.php');
	
	$project_id = $_GET['project_id'];
	
	//数据过滤和处理

	if (! get_magic_quotes_gpc()) {
	$project_id=addslashes ($project_id);
	}
	
	$db = db_connect();
	$query="select projects.code as project_code, projects.name as project_name, projects.sale as sale_id, projects.entrust_date, projects.ei_p, projects.st_p, projects.pi_p, projects.ve_p, projects.me_p, users.name as sale_name from projects inner join users on projects.sale = users.id where projects.id = '".$project_id."'";
	
	$result=$db->query ($query);
	$num_result=$result->num_rows;
	
	//拿出数据
	$row=$result->fetch_assoc ();
	$project_code = stripslashes ($row['project_code']);
	$project_name = stripslashes ($row['project_name']);
	$sale_name = stripslashes ($row['sale_name']);
	$sale_id = stripslashes ($row['sale_id']);
	$ei_p = stripslashes ($row['ei_p']);
	$st_p = stripslashes ($row['st_p']);
	$pi_p = stripslashes ($row['pi_p']);
	$ve_p = stripslashes ($row['ve_p']);
	$me_p = stripslashes ($row['me_p']);

	
	$result->free();
	
	//列出编号基本信息
	echo "
		<br />
		<div class='row'>
			<div class='col-md-2'><p class='text-right'>报价编号：</p></div>
			<div class='col-md-2'><p>".$project_code."</p></div>
			<div class='col-md-2'><p class='text-right'>项目名称：</p></div>
			<div class='col-md-4'><p>".$project_name."</p></div>
			<div class='col-md-1'><p class='text-right'>销售：</p></div>
			<div class='col-md-1'><p>".$sale_name."</p></div>
		</div>
		<br />
	";
	
	

	
	echo "
	
	<form class='form-horizontal' role='form' action = '../PHP/edit_noted_project.php' method = 'post'>
		<input type='hidden' name = 'project_id' value = '".$project_id."'>
		<div class='form-group'>
			<label for='ei_p' class='col-md-2 control-label'>电仪标书要求：</label>
			<div class='col-md-10'>
				<textarea class='form-control' rows='2' name='ei_p'>".$ei_p."</textarea>
			</div>
		</div>
		
		<div class='form-group'>
			<label for='st_p' class='col-md-2 control-label'>结构标书要求：</label>
			<div class='col-md-10'>
				<textarea class='form-control' rows='2' name='st_p'>".$st_p."</textarea>
			</div>
		</div>
		
		<div class='form-group'>
			<label for='pi_p' class='col-md-2 control-label'>管道标书要求：</label>
			<div class='col-md-10'>
				<textarea class='form-control' rows='2' name='pi_p'>".$pi_p."</textarea>
			</div>
		</div>
		
		<div class='form-group'>
			<label for='ve_p' class='col-md-2 control-label'>容器标书要求：</label>
			<div class='col-md-10'>
				<textarea class='form-control' rows='2' name='ve_p'>".$ve_p."</textarea>
			</div>
		</div>
		
		<div class='form-group'>
			<label for='me_p' class='col-md-2 control-label'>机械标书要求：</label>
			<div class='col-md-10'>
				<textarea class='form-control' rows='2' name='me_p'>".$me_p."</textarea>
			</div>
		</div>
	
		<br />
		<div class='form-group'>
			<div class='col-md-offset-2 col-md-3'>
				<input class='btn btn-success' type = 'submit' value='修改'/>
			</div>
		</div>
	</form>
	
	";
	
	
}

if (isset($_POST['project_id'])) {
	
	require_once ('../FNS/db_fns.php');
	
	$project_id = trim($_POST['project_id']);
	$ei_p = trim($_POST['ei_p']);
	$pi_p = trim($_POST['pi_p']);
	$st_p = trim($_POST['st_p']);
	$ve_p = trim($_POST['ve_p']);
	$me_p = trim($_POST['me_p']);
		
	//数据过滤和处理
	//加引号避免输入数据库出错
	if (! get_magic_quotes_gpc()) {	
	$project_id = addslashes ($project_id);
	$ei_p = addslashes ($ei_p);
	$st_p = addslashes ($st_p);
	$pi_p = addslashes ($pi_p);
	$ve_p = addslashes ($ve_p);
	$me_p = addslashes ($me_p);
	}
	//连接数据库并插入数据

	$db= db_connect();

	$query="update projects set ei_p = '".$ei_p."', st_p = '".$st_p."', pi_p = '".$pi_p."', ve_p = '".$ve_p."', me_p = '".$me_p."' where id = '".$project_id."'";
	$result=$db->query ($query);
	if ($result){
		echo "<br />";
		echo "修改成功，请查询确认。";
	}else{
	echo "<br />";
	echo"修改失败，请重新查询！";
	
	
	}
	
	$db->close();
	
	}





?>


</div>
</body>
</html>
